<!DOCTYPE html>
<html>
 <head> 
  <title>Laravel5.1配置--闫海的个人博客-芒果小叨</title> 
  <!-- meta tags start --> 
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  <meta name="Keywords" content="个人博客,闫海个人博客,laravel5.1,laravel5,laravel,la" /> 
  <meta name="Description" content="上一篇文章中安装好Laravel5.1后，你会发现访问时多了个public,懂apache配置的同学自己配一下就可以去掉这个public。这里还是顺带提一下。" /> 
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> 
  <!-- meta tags end -->
  <!-- favorite icon starts -->
  <link rel="shortcut icon" href="/Public/Index/mobile/images/common/favicon.ico" type="image/x-icon" />
  <!-- favorite icon ends -->
  <!-- CSS files start -->
  <link href="/Public/Index/mobile/css/framework.css" rel="stylesheet" type="text/css" media="all" />
  <link href="/Public/Index/mobile/css/colorbox.css" rel="stylesheet" type="text/css" media="all" />
  <link href="/Public/Index/mobile/css/responsive.css" rel="stylesheet" type="text/css" media="screen" />
  <link href="/Public/Index/mobile/css/hidpi.css" rel="stylesheet" type="text/css" media="screen" />
  <link href="/Public/Index/mobile/css/skin.css" rel="stylesheet" type="text/css" media="all" />
  <link href="/Public/Index/mobile/css/custom.css" rel="stylesheet" type="text/css" media="all" />
  <link href="/Public/Index/mobile/css/elements.css" rel="stylesheet" type="text/css" media="all" />
  <link href="/Public/Index/mobile/css/style.css" rel="stylesheet" type="text/css" media="all" />
  
  <!-- CSS files end -->
  <!-- JavaScript files start --> 
  <script type="text/javascript" src="/Public/Index/mobile/grayscale.js"></script>
  <script type="text/javascript" src="/Public/Index/mobile/js/jquery.min.js"></script>
  <script type="text/javascript" src="/Public/Index/mobile/js/effects.jquery-ui.min.js"></script>
  <script type="text/javascript" src="/Public/Index/mobile/js/jquery.nivo-slider.min.js"></script>
  <script type="text/javascript" src="/Public/Index/mobile/js/custom.js"></script>
  <script type="text/javascript" src="/Public/Index/mobile/js/jquery.colorbox.min.js"></script>
  
  <!-- JavaScript files end -->
 </head>
 <body>
  <!-- website wrapper starts -->
  <div class="websiteWrapper"> 
   <!-- main menu wrapper starts --> 
   <div class="mainMenuOuterWrapper"> 
    <a href="#" class="mainMenuCloseButton"></a> 
    <ul class="mainMenuWrapper"> 
     <li class="currentPage"><a href='/mobile.php/index.html' title='首页'>首页</a></li>
      <li><a href='/mobile.php/list/2.html' title='关于我'>关于我<span> </span></a></li><li><a href='/mobile.php/list/3.html' title='时光轴'>时光轴<span> </span></a></li><li><a href='/mobile.php/list/1.html' title='品味人生'>品味人生<span> </span></a></li><li><a href='/mobile.php/list/5.html' title='技术分享'>技术分享<span> </span></a></li>     <li><a href='/mobile.php/index/article/message.html'  title='给我留言'>给我留言</a></li>
    </ul> 
   </div> 
   <!-- main menu wrapper ends --> 

<script type="text/javascript">
  var url = '/mobile.php/article';
  $(function(){
    var id = '47';
    $.post(url+'/addClick',{'id':id},function(data){
        $("#pclick").html('点击数：' + data);
    });
  })
</script>
   <!-- header wrapper starts --> 
   <div class="headerOuterWrapper pageHeaderWrapper"> 
    <div class="headerWrapper"> 
     <a class="mainLogo" href="/mobile.php/index.html"><img src="/Public/Index/mobile/images/mainLogo.png" alt="" /></a> 
     <a href="#" class="mainMenuButton"></a>
    </div>
    <!-- page title starts --> 
    <h5 class="pageTitle">当前位置：
	<a href="/mobile.php/index.html">首页</a>&nbsp;&gt;&nbsp;
	<a href="/mobile.php/list/5.html">技术分享</a>
	&nbsp;&gt;&nbsp;<a href="/mobile.php/list/17.html">Laravel教程</a>
	</h5>    <!-- page title ends --> 
   </div>
   <!-- header wrapper ends --> 
   <!-- page wrapper starts --> 
   <div class="pageWrapper singlePostPageWrapper"> 
    <!-- post content wrapper starts --> 
    <div class="singlePostContentWrapper">
    <h3 class="pageTitle" style="background:#F0F0F0;color:#333;text-align:center;">Laravel5.1配置</h3> 
     <div class="pageSpacer"></div> 
     <div class="pageSpacer"></div> 
     <div style="word-break: break-all;" class="phoneContent"><p><span style="color: rgb(0, 0, 0);">上一篇文章中安装好Laravel5.1后，你会发现访问时多了个public,懂apache配置的同学自己配一下就可以去掉这个public。这里还是顺带提一下。</span></p><p><span style="color: rgb(0, 0, 0);">比如你用的windows操作系统，安装的XAMPP，那么你可以照着来操作：</span></p><p><span style="color: rgb(0, 0, 0);">这里默认你已经安装了composer，并安装好了XAMPP。比如我想自己的项目叫做la，那需要在xampp/htdocs/中建立la文件夹，然后把你的<a style="color: rgb(0, 176, 240); text-decoration: underline;" target="_blank" href="https://github.com/laravel/laravel/archive/v5.1.0.zip"><span style="color: rgb(0, 176, 240);">laravel5.1</span></a>（下载其他版本可以<a style="color: rgb(0, 176, 240); text-decoration: underline;" target="_blank" href="https://github.com/laravel/laravel/"><span style="color: rgb(0, 176, 240);">点这里</span></a>，点branch：master然后在tags中选择版本，然后download）下载后解压到la文件夹中。</span></p><p><span style="color: rgb(0, 0, 0);">（为了演示一个多站点配置，在新建一个test文件夹做测试，里面放一个index.php）,写入：</span></p><pre class="brush:php;toolbar:false">&lt;?php
phpinfo();</pre><p><span style="color: rgb(0, 0, 0);">接下来配置XAMPP多站点。修改C盘WINDOWS\system32\drivers\etc目录下的 hosts 文件，添加：</span></p><pre class="brush:bash;toolbar:false">127.0.0.1&nbsp;mytest.com
127.0.0.1&nbsp;test.com</pre><p><span style="color: rgb(0, 0, 0);">打开xampp\apache\conf\httpd.conf文件，搜索 “Include conf/extra/httpd-vhosts.conf”，确保前面没有 # 注释符，也就是确保引入了 vhosts 虚拟主机配置文件。</span></p><p><span style="color: rgb(0, 0, 0);">在虚拟主机设置文件xampp\apache\conf\extra\httpd-vhosts.conf里设置：取消 NameVirtualHost *:80 前面的 ##，这样就启用了 vhosts.conf ，默认的httpd.conf默认配置失效。虚拟主机配置将只设置在 httpd-vhosts.conf 里。</span></p><p><span style="color: rgb(0, 0, 0);">添加：</span></p><pre class="brush:bash;toolbar:false">&lt;VirtualHost&nbsp;*:80&gt;
&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot&nbsp;&quot;E:/xampp/htdocs/la/public&quot;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;mytest.com
&lt;/VirtualHost&gt;
&lt;Directory&nbsp;&quot;E:/php/wordpress&quot;&gt;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Options&nbsp;Indexes&nbsp;FollowSymLinks&nbsp;Includes&nbsp;ExecCGI&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride&nbsp;All&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Order&nbsp;allow,deny&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Allow&nbsp;from&nbsp;all
&lt;/Directory&gt;
&lt;VirtualHost&nbsp;*:80&gt;
&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot&nbsp;&quot;E:/xampp/htdocs/test&quot;
&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;test.com
&lt;/VirtualHost&gt;
&lt;Directory&nbsp;&quot;E:/php/wordpress&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;Options&nbsp;Indexes&nbsp;FollowSymLinks&nbsp;Includes&nbsp;ExecCGI&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride&nbsp;All&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Order&nbsp;allow,deny&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Allow&nbsp;from&nbsp;all
&lt;/Directory&gt;
&lt;VirtualHost&nbsp;*:80&gt;
&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot&nbsp;&quot;E:/xampp/htdocs/&quot;
&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;localhost
&lt;/VirtualHost&gt;</pre><p><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">重启apache。参照</span><a style="text-decoration: underline; color: rgb(0, 176, 240);" target="_blank" href="http://www.yanhai0531.com/index/article/46.html"><span style="color: rgb(0, 176, 240);">之前的文章</span></a>，配置composer.json添加日本镜像，然后cmd中：</p><pre class="brush:bash;toolbar:false">E:
cd&nbsp;xampp/htdocs/la
composer&nbsp;install</pre><p>安装laravel<span style="color: rgb(0, 0, 0);">框架依赖包</span>，<span style="color: rgb(0, 0, 0);">把根目录的</span><code><span style="color: rgb(0, 0, 0);">.enb.example</span></code><span style="color: rgb(0, 0, 0);">重命名.env，<span style="color: rgb(0, 0, 0);">随机生成一个项目的加密key</span>，然后访问mytest.com,你会同样看到laravel的欢迎信息。。然后访问test.com你会发现phpinfo输出的信息。这样多站点就配置完成了。</span></p><p><span style="color: rgb(0, 0, 0);">顺带提一下，laravel中的默认时间是UTC，我们需要改成中国时间，在config/app.php中修改为&#39;timezone&#39; =&gt; &#39;PRC&#39;就可以了。</span></p></div>
     <div class="textBreak"></div> 
    </div> 
    <!-- post content wrapper ends --> 
    <!-- post info starts --> 
    <div class="singlePostInfoWrapper">
     <span class="singleIconWrapper singleIconText iconCalendarDark postInfo postDate">2015-06-12</span>
     <a class="singleIconWrapper singleIconText iconEditDark postInfo postAuthor postInfoNoMargin">小叨</a>&nbsp;&nbsp;
     <span class="singleIconWrapper singleIconText iconArrowRightDark" id="pclick">点击数：322</span>
    </div> 
    <!-- post info ends --> 
    <!-- post links wrapper starts --> 
    <div class="singlePostContentWrapper"> 
     <p>上一篇：<a href="/mobile.php/article/46.html">laravel5.1安装</a></p>
     <p>下一篇：<a href="/mobile.php/article/48.html">【Laravel5教程】mac+apache+mysql配置多站点(一)</a></p>
    </div> 
    <!-- post links wrapper ends --> 
    <!-- comments section wrapper starts --> 
    <div class="commentsSectionWrapper"> 
     <h4 class="commentsTitle">相关阅读：</h4> 
     <!-- comments wrapper starts --> 
     <!-- accordion item wrapper starts --> 
        <div class="accordionContent"> 
         <p><a href="/mobile.php/article/48.html" title="【Laravel5教程】mac+apache+mysql配置多站点(一)">【Laravel5教程】mac+apache+mysql配置多站点(一)</a></p><p><a href="/mobile.php/article/47.html" title="Laravel5.1配置">Laravel5.1配置</a></p><p><a href="/mobile.php/article/46.html" title="laravel5.1安装">laravel5.1安装</a></p><p><a href="/mobile.php/article/45.html" title="初探Laravel5">初探Laravel5</a></p>        </div> 
     <!-- accordion item wrapper ends -->
     <!-- coments wrapper ends --> 
    </div> 
    <!-- comments section wrapper ends --> 
   </div> 
   <!-- page wrapper ends --> 
   <!-- footer wrapper starts --> 
   <div class="footerWrapper"> 
    <!-- copyright wrapper starts --> 
    <div class="copyrightWrapper"> 
     <!-- copyright starts --> 
     <span class="copyright"><a href="http://www.miitbeian.gov.cn/">鲁ICP备15004472号-1</a></span> 
     <!-- copyright ends --> 
     <!-- back to top button starts --> 
     <a href="" class="backToTopButton"></a> 
     <!-- back to top button ends --> 
    </div> 
    <!-- copyright wrapper ends --> 
   </div> 
   <!-- footer wrapper ends --> 
  </div>
  <!-- website wrapper ends -->
 </body>
</html>